<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>提示信息管理--新增</title>
  <link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
  <link rel="stylesheet" type="text/css" href="../../themes/icon.css">
  <script type="text/javascript" src="../../easyui/js/jquery.min.js"></script>
  <script type="text/javascript" src="../../easyui/js/jquery.easyui.min.js"></script>
  <link href="https://unpkg.com/@wangeditor/editor@latest/dist/css/style.css" rel="stylesheet">
  <style>
    body {
      font-size: 14px;
    }
    a {
      display: inline-block;
      text-decoration: none;
      color: #000;
      padding: 0;
      margin: 0;
    }
    .title {
      width: 100%;
      height: 50px;
      line-height: 50px;
      border-bottom: 3px solid #000;
    }
    .form-item{
      margin-top: 10px;
    }
    .form-item .save, .form-item .cancel{
      width: 80px;
      height: 35px;
      line-height: 35px;
      text-align: center;
      font-size: 16px;
      border-radius: 5px;
      float: left;
      cursor: pointer;
      margin-top: 30px;
    }
    .form-item .save{
      color: #fff;
      background: rgba(64, 158, 255, 1);
    }
    .form-item .cancel{
      color: #333;
      background: #eeeeee;
      margin-left: 20px;
    }
    .form-item label{
      display: inline-block;
      width: 80px !important;
      text-align: right;
    }
    #editor—wrapper {
      border: 1px solid #cccccc;
      z-index: 100; /* 按需定义 */
    }
    #toolbar-container { border-bottom: 1px solid #cccccc; }
    #editor-container { height: 500px; }
    p {
      /* 将p的margin改为0, 不然会出现改了#editor-container的高度，编辑器已经足够放下内容了，但是仍然会有滚动条出现的问题 */
      margin: 0 !important;
      line-height: 1.3em;
    }

    .w-e-scroll>div:first-child {
      padding-top: 15px; /* 将输入起始位置与“请输入内容对齐” */
    }
  </style>
</head>
<body>
<div class="content">
  <div class="title">编辑</div>
  <form class="form-content" id="ff" method="post">
    <div class="form-item">
      <label for="crowd">提示信息：</label>
      <input class="easyui-validatebox" placeholder="输入内容" type="text" id="crowd" name="crowd" style="width: 270px;height: 30px;"/>
    </div>
    <div class="form-item">
      <label for="sort">排序：</label>
      <input type="text" class="easyui-numberbox" id="sort" value="100" data-options="min:0">
    </div>
    <div class="form-item">
      <label>内容：</label>
      <div id="editor—wrapper" οnscrοll="true" >
        <div id="toolbar-container"><!-- 工具栏 -->
        </div>
        <div id="editor-container"><!-- 编辑器 --></div>
      </div>
    </div>
    <div class="form-item">
      <div class="save">新增</div>
      <div class="cancel">取消</div>
    </div>
  </form>
  <script src="https://unpkg.com/@wangeditor/editor@latest/dist/index.js"></script>
  <script>
    $(function(){

      const { createEditor, createToolbar } = window.wangEditor
      const editorConfig = {
        MENU_CONF: {},
        placeholder: 'Type here...',
        onChange(editor) {
          const html = editor.getHtml();
          console.log('editor content', html)
        }
      }
      editorConfig.MENU_CONF['uploadImage'] = {
        server: '',
        timeout: 50 * 1000, // 5s
        fieldName: 'file',//上传字段
        metaWithUrl: true, // join params to url
        // headers: { Accept: 'text/x-json' },

        maxFileSize: 10 * 1024 * 1024, // 10M

        onBeforeUpload(file) {
          console.log('onBeforeUpload', file)
          return file // will upload this file
          // return false // prevent upload
        },
        onSuccess(file, res) {
          console.log('onSuccess', file, res)
        },
        onFailed(file, res) {
          alert(res.message)
          console.log('onFailed', file, res)
        },
        onError(file, err, res) {
          alert(err.message)
          console.error('onError', file, err, res)
        },
      }
      const toolbarConfig = {}
      toolbarConfig.excludeKeys = [
        'uploadVideo' // 排除菜单组，写菜单组 key 的值即可
      ]
      const editor = createEditor({
        selector: '#editor-container',
        html: '<p><br></p>',
        config: editorConfig,
        mode: 'default', // or 'simple'
      })

      const toolbar = createToolbar({
        editor,
        selector: '#toolbar-container',
        // config: {}
        config: toolbarConfig,
        mode: 'default', // or 'simple'
      })
    })
  </script>
</div>
</body>
</html>
